# CMakeList.txt: CMakeProject1 的 CMake 项目，在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required (VERSION 3.16)

# 如果支持，请为 MSVC 编译器启用热重载。
if (POLICY CMP0141)
  cmake_policy(SET CMP0141 NEW)
  set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CONFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

project ("CMakeProject1")

set(CMAKE_CXX_STANDARD 14)
# 根据平台设置特定的变量和路径
if(WIN32)
    # Windows特定设置
    set(THIRD_LIB_PATH ${PROJECT_SOURCE_DIR}/third_lib/win_install)
    set(CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/third_lib/win_install")
    list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/third_lib/win_install/jsoncpp")
    set(GTEST_ROOT "${PROJECT_SOURCE_DIR}/third_lib/win_install/googletest")
else()
    # Linux特定设置
    set(THIRD_LIB_PATH ${PROJECT_SOURCE_DIR}/third_lib/linux_install)
    set(CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/third_lib/linux_install")
    list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/third_lib/linux_install/jsoncpp")
    set(GTEST_ROOT "${PROJECT_SOURCE_DIR}/third_lib/linux_install/googletest")
endif()

find_package(glog REQUIRED)
find_package(gflags REQUIRED)
find_package(GTest REQUIRED)
find_package(jsoncpp REQUIRED)
# 包含第三方库的头文件目录和库目录
include_directories(${THIRD_LIB_PATH}/glog/include)
include_directories(${THIRD_LIB_PATH}/googletest/include)
include_directories(${THIRD_LIB_PATH}/gflags/include)
include_directories(${THIRD_LIB_PATH}/jsoncpp/include)


link_directories(${THIRD_LIB_PATH}/glog/lib)
link_directories(${THIRD_LIB_PATH}/googletest/lib)
link_directories(${THIRD_LIB_PATH}/gflags/lib)
link_directories(${THIRD_LIB_PATH}/jsoncpp/lib)

# 添加子目录
add_subdirectory(${PROJECT_SOURCE_DIR}/src)
add_subdirectory(test)
